<?php
/**
* @package Pages-and-Items (com_pi_pages_and_items)
* @version 1.5.7
* @copyright Copyright (C) 2006-2010 Carsten Engel. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @author http://www.pages-and-items.com
*/

//no direct access
if(!defined('_VALID_MOS') && !defined('_JEXEC')){
	die('Restricted access');
}

//global $mainframe;//needed for joomla 1.0.x frontend editting

//only access for the right usertypes
if($frontend){	
	$allowed_user_types = array('Author','Editor','Publisher','Manager','Administrator','Super Administrator');	
}else{	
	$allowed_user_types = array('Manager','Administrator','Super Administrator');	
}
if(!in_array($class_pi->user_type, $allowed_user_types)){
	die('You have no permission to edit content');
}

if($frontend){
	$class_pi->check_comp();
}

//get item_id
if($frontend){
	$item_id = $class_pi->get_var('item_id', '' );	
}else{
	$item_id = $class_pi->get_var('itemId', '' );
}

//get page_id
$page_id = $class_pi->get_var('pageId', '' );

//get date and time
$datenow = $class_pi->get_date_now(true);

//switch for new and edit
if($sub_task=='new'){
	//begin getting data for new item	
	
	
	
	//check if user has right to make a new item
	if($class_pi->checkUserActionRight(10)!=true){
		echo '<script> alert(\''._pi_lang_no_new_item.'\'); window.history.go(-1); </script>';
		exit();
	}	
	
	//check section access. don't check if from frontend, sections and category select will be filtered out
	if(!$frontend){
		if(!$class_pi->check_section_access_by_pageid($page_id)){
			echo "<script> alert('"._pi_lang_nosectionaccess."'); window.history.go(-1); </script>";
			exit();
		}
	}
	
	//get category id of menuitem
	$cat_id = '';	
	$section_id = '';
	if(!$frontend){
		$class_pi->db->setQuery("SELECT id, link, componentid FROM #__menu WHERE id='$page_id' LIMIT 1");
		$rows = $class_pi->db->loadObjectList();
		$row = $rows[0];	
		if( defined('_JEXEC') ){
			//joomla 1.5
			$cat_id = str_replace('index.php?option=com_content&view=category&layout=blog&id=','',$row->link);
		}else{
			//joomla 1.0.x
			$cat_id = $row->componentid;	
		}	
	
		//get the section which the category belongs to	
		$class_pi->db->setQuery("SELECT id, section, name FROM #__categories WHERE id='$cat_id'");//name?
		$rows = $class_pi->db->loadObjectList();
		$row = $rows[0];
		$section_id = $row->section;
	}
	
	//get category and section id from url
	if($frontend){
		$section_id = intval($class_pi->get_var('section', '' ));	
		$cat_id = intval($class_pi->get_var('category', '' ));
		$hide_page_select = $class_pi->get_var('hide_select', '' );
	}
	
	//set vars for new item
	$item_id = '';
	$itemTitle = '';
	$itemTitleAlias = '';
	$itemIntroText = '';
	$itemFullText = '';
	$text = '';
	$itemFrontpage = $class_pi->pi_config['item_new_frontpage'];
	$show_title_item = $class_pi->pi_config['item_new_show_title'];
	$itemState = $class_pi->pi_config['item_new_state'];
	$itemAccess = $class_pi->pi_config['item_new_access'];
	$itemCreatedByAlias = '';
	$itemMetadesc = '';
	$itemMetakey = '';
	$user_id = '';
	$created = $datenow;
	$created_by = $class_pi->user_id;
	$item_publish_up = $datenow;
	$item_publish_down = _pi_lang_never;
	$version = '0';
	$item_type = $class_pi->get_var('item_type', 'text');	
	$language = $class_pi->pi_config['item_language'];
	$readmore = $class_pi->pi_config['item_readmore'];
		
	$metadata_thing['robots'] = '';
	$metadata_thing['author'] = '';
	$values = array();
	$values['introtext'] = 1;
	$values['item_title'] = 1;
	
	$itemAttribs = 'show_title=
show_pdf_icon=
show_print_icon=
show_email_icon=
link_titles=
show_intro=
show_section=
link_section=
show_category=
link_category=
show_vote=
show_author=
show_create_date=
show_modify_date=
keyref=
language=en-GB
readmore=
';
	//add extra attributes so Joomla 1.0.x can deal with this
$itemAttribs .=	'pdf=
print=
email=
back_button=
section=
section_link=
category=
category_link=
rating=
author=
createdate=
modifydate=
docbook_type=
link_titles=
keyref=
pageclass_sfx=
link_titles=
';
	
	//explode array attributes
	
	$itemAttribs = explode( "\n", $itemAttribs);	
	for($n = 0; $n < count($itemAttribs); $n++){		
		$temp = explode('=',$itemAttribs[$n]);
		$var = $temp[0];
		$value = '';
		if(count($temp)==2){
			$value = $temp[1];
		}							
		$values[$var] = trim($value);	
	}	
	
	
	
	//end getting data for new item
	?>
	
	<script language="javascript" type="text/javascript">
		<!--
		
		<?php
		//needed to rename the function for frontend because the javascript function got overwritten somewhere by the core
		if($frontend){
		?>
		function submitbutton2(pressbutton) {
		<?php
		}else{
		?>	
		function submitbutton(pressbutton) {
		<?php
		}
		?>	
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}	
			if (pressbutton == 'item_apply') {
				document.getElementById('item_apply').value = 1;						
			}	
			if (pressbutton == 'item_apply' || pressbutton == 'item_save') {
				item_title = document.adminForm.title.value;
				item_title = trim(item_title);		
				
				if (item_title == '') {
					alert('<?php echo _pi_lang_no_title; ?>');					
					return;
				<?php
				if($frontend){
				?>
					}else if(document.adminForm.cat_id.value == '' || document.adminForm.cat_id.value=='0'){
						alert('<?php echo _pi_lang_no_page_selected; ?>');					
						return;	
				<?php
				}
				?>			
				} else {
					<?php
						//if custom itemtype
						if(strpos($item_type, 'ustom_')){
					?>
							if(validate_custom_itemtype_fields()){
					<?php
						//if itemtype plugin
						}elseif($item_type!='text' && $item_type!='html' && $item_type!='other_item'){							
					?>
							if(validate_itemtype()){
					<?php							
						}
					?>
							submitform('item_save');
					<?php
						//if custom itemtype or itemtype plugin
						if($item_type!='text' && $item_type!='html' && $item_type!='other_item'){
					?>
							}
					<?php
						}
					?>
				}
			}
		}	
		
		-->
	</script>
	<?php
}else{
	//begin getting data to edit item
	
	//check edit-page-link rights	
	if(!$class_pi->checkUserActionRight(11)){
		echo "<script> alert('"._pi_lang_noedititem."'); window.history.go(-1); </script>";
		exit();
	}	
	
	if($frontend){
		if(!$class_pi->check_page_access($page_id)){
			echo '<script> alert(\''._pi_lang_no_edit_page.'\'); window.history.go(-1); </script>';
			exit();
		}
	}
	
	//check item access
	if(!$class_pi->check_item_access($item_id)){
		echo "<script> alert('"._pi_lang_noitemaccess."'); window.history.go(-1); </script>";
		exit();
	}
	
	//data from item		
	$class_pi->db->setQuery("SELECT * FROM #__content WHERE id='$item_id' LIMIT 1");
	$rows = $class_pi->db->loadObjectList();
	$row = $rows[0];	
	
	$item_id = $row->id;
	$itemTitle = htmlspecialchars($row->title);	
	
	if(defined('_JEXEC')){
		//joomla 1.5
		$itemTitleAlias = htmlspecialchars($row->alias);
	}else{
		//joomla 1.0.x
		$itemTitleAlias = htmlspecialchars($row->title_alias);
	}	
		
	$itemIntroText = htmlspecialchars($row->introtext);
	$itemFullText = htmlspecialchars($row->fulltext);
	if($itemFullText!=''){
		$text = $itemIntroText.'<hr id="system-readmore" />'.$itemFullText;
	}else{
		$text = $itemIntroText;
	}	
	
	$itemState = $row->state;
	$cat_id = $row->catid;
	$section_id = $row->sectionid;			
	$itemCreatedByAlias = $row->created_by_alias;
	$item_publish_up = $row->publish_up;
	$item_publish_up = $class_pi->get_date_to_format($item_publish_up);	
	$item_publish_down = $row->publish_down;
	if($item_publish_down!='0000-00-00 00:00:00'){
		$item_publish_down = $class_pi->get_date_to_format($item_publish_down);	
	}
	$itemMetakey = $row->metakey;
	$itemMetadesc = $row->metadesc;
	$itemAttribs = $row->attribs;
	$version = $row->version;
	$itemAccess = $row->access;
	$item_hits = $row->hits;		
	$created = $row->created;
	$created = $class_pi->get_date_to_format($created);		
	$created_by = $row->created_by;	
	$item_modified = $row->modified;
	$item_modified = $class_pi->get_date_to_format($item_modified);	
	
	if($itemAttribs==''){
		$itemAttribs = 'item_title=1
introtext=1
show_title=
show_pdf_icon=
show_print_icon=
show_email_icon=
link_titles=
show_intro=
show_section=
link_section=
show_category=
link_category=
show_vote=
show_author=
show_create_date=
show_modify_date=
keyref=
language=en-GB
readmore=
';
	//add extra attributes so Joomla 1.0.x can deal with this
$itemAttribs .=	'pdf=
print=
email=
back_button=
section=
section_link=
category=
category_link=
rating=
author=
createdate=
modifydate=
docbook_type=
link_titles=
keyref=
pageclass_sfx=
link_titles=
';
	}
	
	/*
	//testing date stuff
	
	echo $class_pi->get_date_now(0).'<br />';	
	echo 'uit db='.$item_modified.'<br />';	
	$item_modified = $class_pi->get_date_to_format($item_modified);	
	echo 'naar format='.$item_modified.'<br />';
	
		
		$item_modified = $class_pi->get_date_ready_for_database($item_modified);
		
		echo 'naar db='.$item_modified.'<br />';
	*/
	
	if($item_publish_down=='0000-00-00 00:00:00'){
		$item_publish_down = _pi_lang_never;
	}
	
	$user_id = $class_pi->user_id;	

	//check section access
	if(!$class_pi->check_section_access($section_id)){
		echo "<script> alert('"._pi_lang_nosectionaccess."'); window.history.go(-1); </script>";
		exit();
	}
	//exit($cat_id);
	//check category access only for frontend (for backend the edit-page would be not accessible)
	if(!$class_pi->check_category_access($cat_id)){
	
		echo "<script> alert('"._pi_lang_no_category_access."'); window.history.go(-1); </script>";
		exit();
	}
	
	
	//if author only new items and own items can be editted
	if($class_pi->user_type=='Author'){
		//check if the item to edit is the authors own article
		if($class_pi->user_id!=$created_by){
			echo "<script> alert('"._pi_lang_noitemaccess."'); window.history.go(-1); </script>";
			exit();
		}
	}
	
	//if user is only allowed to edit own items
	if($class_pi->checkUserActionRight(175)!=true){		
		if($class_pi->user_id!=$created_by){
			echo "<script> alert('"._pi_lang_you_are_not_author."'); window.history.go(-1); </script>";
			exit();
		}
	}
		
	//explode array attributes
	$itemAttribs = explode( "\n", $itemAttribs);	
	for($n = 0; $n < count($itemAttribs); $n++){
		//list($var,$value) = split('=',$itemAttribs[$n]); 
		//$values[$var] = trim($value); 
		
		$values_temp = explode('=',$itemAttribs[$n]); 
		$var = $values_temp[0];			
		$value = str_replace($var.'=','',$itemAttribs[$n]);
		$value = trim($value);
		$values[$var] = $value;	
	}
	
	//joomla 1.5 only get metadata for robots and author
	if( defined('_JEXEC') ){
		//joomla 1.5
		$metadata = $row->metadata;
		$metadata = explode( "\n", $metadata);	
		for($n = 0; $n < count($metadata); $n++){
			//list($var,$value) = split('=',$metadata[$n]); 
			//$metadata_thing[$var] = trim($value); 
			
			
			$values_temp = explode('=',$metadata[$n]); 
			$var = $values_temp[0];			
			$value = str_replace($var.'=','',$metadata[$n]);
			$value = trim($value);
			$metadata_thing[$var] = $value;	
		}
	}
	
	//get data from item index
	$class_pi->db->setQuery("SELECT * FROM #__pi_item_index WHERE item_id='$item_id' LIMIT 1");
	$rows = $class_pi->db->loadObjectList();
	if($rows){
		$row = $rows[0];	
		$show_title_item = $row->show_title;
		$item_type = $row->itemtype;
	}else{
		$show_title_item = true;
		$item_type = 'text';
	}
	
	if($item_type==''){
		$item_type = 'text';
	}			
		
	//check if item is currently on frontpage
	$class_pi->db->setQuery("SELECT content_id FROM #__content_frontpage WHERE content_id='$item_id' LIMIT 1");
	$rows = $class_pi->db->loadObjectList();	
	if(count($rows)>0){
		$itemFrontpage = true;			
	}else{
		$itemFrontpage = false;
	}	
	
	?>
	<script language="javascript" type="text/javascript">
		<!--
		<?php
		//needed to rename the function for frontend because the javascript function got overwritten somewhere by the core
		if($frontend){
		?>
		function submitbutton2(pressbutton) {
		<?php
		}else{
		?>	
		function submitbutton(pressbutton) {
		<?php
		}
		?>	
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			if (pressbutton == 'item_move_select') {
				document.location.href = 'index2.php?option=com_pi_pages_and_items&task=item_move_select&pageId='+<?php if($frontend){echo 'nothing';}else{echo $page_id;} ?>+'&item_id='+<?php echo $item_id; ?>;
			}
			if (pressbutton == 'item_trash') {				
				if(confirm("<?php echo _pi_lang_sure_trash; ?>")){
					document.getElementById('trash_item').value = 1;			
					submitform('item_save');					
				}
				return false;	
			}
			if (pressbutton == 'item_apply') {				
				if (document.adminForm.title.value == '') {					
					alert('<?php echo _pi_lang_no_title; ?>');
					return;
				} else {
					document.getElementById('item_apply').value = 1;
					do_item_save =true;
				}
			}	
			if (pressbutton == 'item_save') {
				if (document.adminForm.title.value == '') {					
					alert('<?php echo _pi_lang_no_title; ?>');
					return;
				<?php
				if($frontend){
				?>
					}else if(document.adminForm.cat_id.value == '' || document.adminForm.cat_id.value=='0'){
						alert('<?php echo _pi_lang_no_page_selected; ?>');					
						return;	
				<?php
				}
				?>	
				} else {
					do_item_save =true;
				}
			}
			if(do_item_save){
				<?php
					//if custom itemtype
					if(strpos($item_type, 'ustom_')){
				?>
				if(validate_custom_itemtype_fields()){
				<?php					
					}elseif($item_type!='text' && $item_type!='html' && $item_type!='other_item'){//if itemtype plugin
					?>
					if(validate_itemtype()){
					<?php
					}
				?>				
					submitform('item_save');
				<?php
					//if custom itemtype or itemtype plugin
					if($item_type!='text' && $item_type!='html' && $item_type!='other_item'){
				?>
				}
				<?php
					//if custom itemtype
					}
				?>
				
			}
		}
		-->
	</script>
	<?php
}//end getting data to edit item

//javascript for frontend to set section and category from select
if($frontend){
?>
<script language="javascript" type="text/javascript">
<!--
function set_section_and_category(section_category){				
	pos = section_category.indexOf("_");			
	category = section_category.substr((pos+1),section_category.length);				
	document.getElementById('cat_id').value = category;
	section = section_category.substr(0,pos);
	document.getElementById('section_id').value = section;				
}

function set_section(section){				
	document.getElementById('section_id').value = section;				
}

function set_category(section_category){							
	document.getElementById('cat_id').value = category;							
}	
-->
</script>
	
<?php
}		


//set empty item_type to text
if($item_type==''){
	$item_type = 'text';
}

//check if user has permission to this itemtype
if(!$class_pi->check_useraccess_itemtype($item_type)){
	echo '<script> alert(\''._pi_lang_noitemtype.'\'); window.history.go(-1); </script>';
	exit();
}

//if itemtype does not seem to be installed and its not a custom itemtype, throw error
if($item_type!='text' && $item_type!='html' && $item_type!='other_item' && !strpos($item_type, 'ustom_')){
	if(!file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/'.$item_type.'.php')){		
		echo '<script> alert(\''._pi_lang_itemtypenotinstalled.$item_type.'\'); window.history.go(-1); </script>';
		exit();
	}
}

//if itemtype is not published, throw error
if (!in_array($item_type, $class_pi->itemtypes)){
	echo '<script> alert(\''._pi_lang_itemtypenotpublished.$item_type.'\'); window.history.go(-1); </script>';
	exit();
}

//get itemtype specific config
if(file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/'.$item_type.'.php')){		
	$pi_plugin_config = $class_pi->get_itemtype_config($item_type);
}

//give headers in Joomla 1.5 a bit more spunk
$class_pi->spunk_up_headers_1_5();

//echo 'frontend'.$frontend;

if(!$frontend){
	echo '<table cellspacing="0" cellpadding="0" border="0" width="100%">';
	echo '<tr><td  valign="top" width="25%">';
	$class_pi->pages();
	echo '</td><td valign="top">';
}


if($frontend){
	echo '<form name="adminForm" method="post" action="index.php?option=com_pi_pages_and_items&task=item_save"  enctype="multipart/form-data">';
}else{
	echo '<form name="adminForm" method="post" action="" enctype="multipart/form-data">';
}		
	
?>	
	
		<input type="hidden" name="option" id="option" value="com_pi_pages_and_items" />
		<input type="hidden" name="task" value="item_save" />
		<input type="hidden" name="trash_item" id="trash_item" value="" />
		<input type="hidden" name="item_apply" id="item_apply" value="" />
		<input type="hidden" name="id" value="<?php echo $item_id; ?>" />
		<input type="hidden" name="item_id" value="<?php echo $item_id; ?>" />
		<input type="hidden" name="cat_id" id="cat_id" value="<?php echo $cat_id; ?>" />
		<input type="hidden" name="section_id" id="section_id" value="<?php echo $section_id; ?>" />
		<input type="hidden" name="page_id" id="page_id" value="<?php echo $page_id; ?>" />
		<!--<input type="hidden" name="modified" value="<?php echo date("Y-m-d H:i:s"); ?>" />-->
		<input type="hidden" name="modified_by" value="<?php echo $user_id; ?>" />
		<!--<input type="hidden" name="created" value="<?php echo $created; ?>" />-->
		<input type="hidden" name="created_by" value="<?php echo $created_by; ?>" />
		<input type="hidden" name="version" value="<?php echo ($version+1); ?>" />
		<input type="hidden" name="item_type" value="<?php echo $item_type; ?>" />
		<input type="hidden" name="edit_from_frontend" value="<?php if($frontend){echo '1';} ?>" />
				
		<?php
		
			//slide-script for joomla 1.5 if needed
			if(defined('_JEXEC') && $class_pi->pi_config['item_menu']=='slide'){
				//joomla 1.5
				?>
					<script language="javascript" type="text/javascript">
						//get tabs to work
						window.addEvent('domready', function(){ new Accordion($$('.panel h3.jpane-toggler'), $$('.panel div.jpane-slider'), {onActive: function(toggler, i) { toggler.addClass('jpane-toggler-down'); toggler.removeClass('jpane-toggler'); },onBackground: function(toggler, i) { toggler.addClass('jpane-toggler'); toggler.removeClass('jpane-toggler-down'); },duration: 300,opacity: false}); });
					</script>
				<?php
			}
			
			if($frontend){
				$path_to_root = '';	
			}else{
				$path_to_root = '../';	
			}
			
			//get tabs-script
			echo '<link type="text/css" rel="stylesheet" href="'.$path_to_root.'includes/js/tabs/tabpane.css" />';
			
			//layout and script for frontend
			if($frontend){
				echo '<script type="text/javascript" src="includes/js/joomla.javascript.js"></script>';
				echo '<script type="text/javascript" src="media/system/js/mootools.js"></script>';  
				//echo '<link type="text/css" rel="stylesheet" href="administrator/templates/khepri/css/template.css" />';
				echo '<link type="text/css" rel="stylesheet" href="administrator/components/com_pi_pages_and_items/css/pages_and_items3.css" />';				
   				echo '<script src="includes/js/overlib_mini.js" language="JavaScript" type="text/javascript"></script>';
			}
			
			
			echo '<script type="text/javascript" src="'.$path_to_root.'includes/js/tabs/tabpane_mini.js"></script>';
		
			//get calender stuff
			if( defined('_JEXEC') ){
				//joomla 1.5
				JHTML::_('behavior.calendar');					
			}else{
				//joomla 1.0.x
				echo '<script type="text/javascript" src="'.$path_to_root.'includes/js/calendar/calendar_mini.js"></script>';
				echo '<script type="text/javascript" src="'.$path_to_root.'includes/js/calendar/lang/calendar-en.js"></script>';
			}//end calender stuff
			
			
			
		
		?>
	
	<style type="text/css">
	
	input.button{
		float: left;
		padding: 0 0 1px 0;
		margin-left: 3px;
	}

	.text_area{
		width: 100px;
	}
	
	.calendar{
		cursor: pointer;
		float: left;
	}
	
	</style>
	
	<?php
	
	/*
						<div class="dynamic-tab-pane-control tab-page" id="tabs_item"><div class="tab-row"><h2 class="tab selected"><a href="#">Publiceren</a></h2><h2 class="tab"><a href="#">&nbsp;&nbsp;Lees verder</a></h2></div>
						*/
	
	//if joomla 1.5 fix left-side of tabs issue
	if( defined('_JEXEC') ){
		//joomla 1.5
		echo '
		<style type="text/css">	
			
			div#tabs_item div.tab-row h2.tab a{
				background: url('.$path_to_root.'administrator/components/com_pi_pages_and_items/images/tab_off.png) no-repeat left top;				
			}
			
			div#tabs_item div.tab-row h2.selected a{
				background: url('.$path_to_root.'administrator/components/com_pi_pages_and_items/images/tab_on.gif) no-repeat left top;
				padding: 2px 10px 3px 10px;
			}
		</style>';
	}
			
	
	//get language for itemtype, defaults to english
	/*
	if($item_type!='text' && $item_type!='html' && $item_type!='other_item' && !strpos($item_type, 'ustom_')){
		if (file_exists(dirname(__FILE__).'/../../com_pi_itemtype_'.$item_type.'/language/'.$class_pi->pi_config['language'].'.php')){
			include(dirname(__FILE__).'/../../com_pi_itemtype_'.$item_type.'/language/'.$class_pi->pi_config['language'].'.php');		
		}else{	
			include(dirname(__FILE__).'/../../com_pi_itemtype_'.$item_type.'/language/english.php'); 			
		}
	}
	*/
	
	if($item_type!='text' && $item_type!='html' && $item_type!='other_item' && !strpos($item_type, 'ustom_')){
		if (file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/language/'.$class_pi->pi_config['language'].'.php')){
			include(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/language/'.$class_pi->pi_config['language'].'.php');		
		}else{	
			include(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/language/english.php'); 			
		}
	}	
	
	
	
	//breadcrumbs only at backend	
	if(!$frontend){	
	?>
	<div id="pi_breadcrumb">
		<a href="index2.php?option=com_pi_pages_and_items&amp;task=page&amp;sub_task=edit&amp;pageId=<?php echo $pageId; ?>"><?php echo _pi_lang_page; ?></a> >  <?php echo _pi_lang_item; ?> [<?php echo $class_pi->translate_item_type($item_type); ?>]<?php	if($sub_task=='new'){echo ' '._pi_lang_new;	}?>
	</div>
	<?php				
	}
	
	//submit buttons only at frontend
	if($frontend){
		echo '<div class="right_align">';
		echo '<input type="button" value="'._pi_lang_save.'" onclick="submitbutton2(\'item_save\')" />&nbsp;&nbsp;&nbsp;';		
		echo '<input type="button" value="'._pi_lang_cancel.'" onclick="history.back();" />';
		echo '</div>';
	}
			
			
		$has_content = '';
		
		if(file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/admin/item_content.php')){
			require_once(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/admin/item_content.php');
			$has_content = 'properties';	
		}		
		
	?>	
	<table class="adminform">
	<tr>
		<th>
			<?php
				echo _pi_lang_item_cap.' '.$has_content;
			?>
		</th>
	</tr>
	<tr>
		<td> 
			<table cellspacing="0" cellpadding="0" border="0" width="100%">
				<tr>
				  <td valign="top"> 
						<div class="pi_wrapper margin0">
							<div class="pi_width70">							
								<div class="pi_wrapper margin0">
									<div class="pi_width20">
										<span onMouseOver="return overlib('<?php echo _pi_lang_worktitle.'. '._pi_lang_requiredfield; ?>', CAPTION, '<?php echo _pi_lang_title; ?>', BELOW, RIGHT);" onMouseOut="return nd();" class="editlinktip" ><?php echo _pi_lang_title; ?></span> : <img src="<?php echo $path_to_root; ?>administrator/components/com_pi_pages_and_items/images/star.gif" alt="required field" />
									</div>
									<div class="pi_width80">
										<input name="title" type="text" class="text_area" style="width: <?php if($frontend){echo '250';}else{echo '300';} ?>px;"  value="<?php echo $itemTitle; ?>" maxlength="100"  />
									</div>	
								</div>
								<div class="pi_wrapper">
									<div <?php if(!$class_pi->check_display_item_property('item_props_alias',88)){echo 'class="display_none"';} ?>>									
										<div class="pi_width20">
											<?php echo _pi_lang_title_alias; ?> :
										</div>
										<div class="pi_width80">
											<input name="title_alias" type="text" class="text_area" id="title_alias" value="<?php echo $itemTitleAlias; ?>"  style="width: <?php if($frontend){echo '250';}else{echo '300';} ?>px;" maxlength="100"   />
										</div>	
									</div>															
								</div>						
							</div>
							<div class="pi_width30">																							
								<div class="pi_wrapper margin0 <?php if(!$class_pi->check_display_item_property('item_props_publish',12)){ echo 'display_none';} ?>">
									<div class="pi_width50">
										<label for="state"><?php echo _pi_lang_publish; ?>:	</label>
									</div>	
									<div class="pi_width20">
										<?php
										
										//check publish rights
										$has_publish_right = false;										
										
										//check aua publish right										
										if($class_pi->pi_config['use_user_access_component'] && $class_pi->user_access_config['active_actions']){
											if($class_pi->checkUserActionRight(12)){
												$has_publish_right = true;	
											}else{
												$has_publish_right = false;	
											}									
										}else{
											if($class_pi->user_type=='Author' || $class_pi->user_type=='Editor'){
												//check author publish right										
												if($class_pi->user_type=='Author' && $class_pi->pi_config['allow_authors_to_publish']){
													$has_publish_right = true;
												}
												
												//check editor publish right										
												if($class_pi->user_type=='Editor' && $class_pi->pi_config['allow_editors_to_publish']){
													$has_publish_right = true;
												}										
											}elseif($class_pi->user_type=='Publisher' || $class_pi->user_type=='Manager' || $class_pi->user_type=='Administrator'){
												$has_publish_right = true;
											}
										}
										
										//super admins can always publish
										if($class_pi->user_type=='Super Administrator'){
											$has_publish_right = true;
										}
										
										
										
										?>
										<input type="checkbox" name="state" id="state" value="1" <?php if($itemState==1){ echo "checked=\"checked\""; } if(!$has_publish_right){ echo 'disabled="disabled"';}?> /> 
										<?php
											if(!$has_publish_right){
												echo '<span onMouseOver="return overlib(\''._pi_lang_no_publish.'\', CAPTION, \'&nbsp;\', BELOW, RIGHT);" onMouseOut="return nd();" class="editlinktip" >&nbsp;?&nbsp;</span>';
											}
										?>
									</div>
								</div>								
								<div class="pi_wrapper <?php if(!$class_pi->check_display_item_property('item_show_frontpage_option',86)){echo 'display_none';} ?>">
									<div class="pi_width50">										
										<label for="frontpage"><?php echo _pi_lang_show_home; ?>:	</label>										
									</div>	
									<div class="pi_width20">
										<input type="checkbox" name="frontpage" id="frontpage" value="1"  <?php if($itemFrontpage==1){ echo "checked=\"checked\""; }?> />
									</div>
								</div>	
							</div>
							
							<?php
							
							if($class_pi->pi_config['create_sef_urls'] && file_exists(dirname(__FILE__).'/../../com_acesef/controller.php')){
								$acesef_metatitle = '';
								$acesef_url_id = '';
								//index.php?option=com_content&Itemid=47&catid=22&id=2587&view=article
								if($sub_task=='edit'){
									$acesef_url = 'index.php?option=com_content&Itemid='.$page_id.'&catid='.$cat_id.'&id='.$item_id.'&view=article';
									
									//get acesef title
									$class_pi->db->setQuery("SELECT id, metatitle FROM #__acesef_urls WHERE url_real='$acesef_url' LIMIT 1");
									$rows = $class_pi->db->loadObjectList();
									foreach($rows as $row){	
										$acesef_metatitle = $row->metatitle;
										$acesef_url_id = $row->id;										
									}
								}
								
								
								?>
								<div class="pi_wrapper" style="float: left;">									
									
									<?php echo _pi_lang_meta_title; ?> :
								
									<input name="acesef_metatitle" type="text" class="text_area" value="<?php echo $acesef_metatitle; ?>"  style="width: 600px;"  />
									<input type="hidden" name="acesef_url_id" value="<?php echo $acesef_url_id; ?>" />
									
								</div>
							<?php 
							}//end if acesef 
							?>
						</div>
						<br /><br />
															
					<?php
						
						//if($frontend && $sub_task=='new'){
						if($frontend){
							//if(!$hide_page_select){
						
								$pi_sections_array = $class_pi->get_sections();
								//print_r($pi_sections_array);
								
								$pi_category_array = $class_pi->get_categories();
								//print_r($pi_category_array);
								
								$pages_array = array();
								if($class_pi->pi_config['new_item_section_category_select']!='section_categories'){
									//make select based on pages in menu
									
									//get all categoryblog pages in an array								
									foreach($class_pi->menuitems as $menu_item_page){								
										if((defined('_JEXEC') && strstr($menu_item_page->link, 'index.php?option=com_content&view=category&layout=blog') && $menu_item_page->type!='url' && $menu_item_page->type=='component') ||
										(!defined('_JEXEC') && $menu_item_page->type=='content_blog_category')
										){	
											if(defined('_JEXEC')){
												//joomla 1.5
												$cat_id_temp = str_replace('index.php?option=com_content&view=category&layout=blog&id=','',$menu_item_page->link);				
											}else{	
												//joomla 1.0.x
												$cat_id_temp = $menu_item_page->componentid;				
											}	
											$pages_array[] = array($menu_item_page->id, $menu_item_page->name, $cat_id_temp);
										}									
									}
									//print_r($pages_array);
								}else{
									//make select based on sections and categories, NOT based on pages in the menu								
									foreach($pi_category_array as $pi_category){
										$category_section_id = $pi_category[2];
										foreach($pi_sections_array as $pi_sections){
											if($pi_sections[0]==$category_section_id){
												$pages_array[] = array('', $pi_category[1], $pi_category[0]);
											}
										}
									}
								}
								//print_r($pages_array);
								
								//make new array combining the 3 arrays and filtering for access
								$array_pages_sections_categories = array();
								for($n = 0; $n < count($pages_array); $n++){
									$page_id = $pages_array[$n][0];
									$page_title = $pages_array[$n][1];
									
									//get the section the pages category is linked to
									for($m = 0; $m < count($pi_category_array); $m++){
										if($pages_array[$n][2]==$pi_category_array[$m][0]){
											$page_cat_id = $pages_array[$n][2];
											$page_section_id = $pi_category_array[$m][2];
											break;
										}
									}
									
									//get section name from id
									for($s = 0; $s < count($pi_category_array); $s++){
										if($page_section_id==$pi_sections_array[$s][0]){
											$page_section_name = $pi_sections_array[$s][1];
											break;
										}
									}
									if($class_pi->check_section_access($page_section_id) && $class_pi->check_category_access($page_cat_id) && $class_pi->check_page_access($page_id)){			
										$array_pages_sections_categories[] = array($page_id, $page_title, $page_section_name, $page_cat_id, $page_section_id);
									}
								}		
								//print_r($array_pages_sections_categories);
								
								//sort array by order
								$column = '';//reset column if you used this elsewhere
								$column = array();
								foreach($array_pages_sections_categories as $sortarray){
									$column[] = $sortarray[1];	
								}
								$sort_order = SORT_ASC;//define as a var or else ioncube goes mad
								array_multisort($column, $sort_order, $array_pages_sections_categories);							
								
								echo '<div>';
								echo _pi_lang_page.' / '.strtolower(_pi_lang_section).': ';
								echo '<select name="pages" onchange="set_section_and_category(this.value)">';
								echo '<option value="0_0">'._pi_lang_select_page2.'</option>';
								for($p = 0; $p < count($array_pages_sections_categories); $p++){
									echo '<option value="'.$array_pages_sections_categories[$p][4].'_'.$array_pages_sections_categories[$p][3].'"';
									//select the current category when edittinig from the frontend
									if($array_pages_sections_categories[$p][3]==$cat_id){
										echo ' selected="selected"';
									}	
									echo '>';
									echo $array_pages_sections_categories[$p][1].' / '.$array_pages_sections_categories[$p][2];
									echo '</option>';
								}
								echo '</select>';
									
																
								echo '</div><br /><br />';	
							//}						
						}
						
						//echo plugin-specific fields														
						if($item_type=='text'){	
							echo stripslashes($class_pi->pi_config['plugin_syntax_cheatcheat']);						
							if(!defined('_JEXEC') ){
								//joomla 1.0.x								
								echo _pi_lang_intro.': <br />';	
								editorArea( 'introtext', $itemIntroText, 'introtext', '100%;', '350', '85', '20' ) ;
								echo '<div>'._pi_lang_newline.'</div><br />';
								echo '<span onMouseOver="return overlib(\''._pi_lang_readontext_tip.'\', CAPTION, \''._pi_lang_readontext.'\', BELOW, RIGHT);" onMouseOut="return nd();" class="editlinktip">'._pi_lang_readontext.'</span>:<br />';								
								editorArea( 'fulltext', $itemFullText, 'fulltext', '100%;', '350', '85', '20' ) ;
								echo '<div>'._pi_lang_newline.'</div>';
							}else{
								//joomla 1.5							
								$editor =& JFactory::getEditor();								
								echo $editor->display( 'text',  $text , '100%', '550', '85', '20' );
							}													
						}elseif($item_type=='html'){
							echo 'HTML:<br /><textarea name="introtext" cols="85" rows="10">'.$itemIntroText.'</textarea>';
						}elseif($item_type=='other_item'){
						
							//get other_items
							$other_item_id = false;
							$class_pi->db->setQuery("SELECT item_id, other_item_id FROM #__pi_item_other_index ");
							$rows_other_items = $class_pi->db->loadObjectList();							
							foreach($rows_other_items as $row_other_item){
								if($row_other_item->item_id==$item_id){
									$other_item_id = $row_other_item->other_item_id;
								}						
							}
							
							//make array to filter other_items out of item list
							$other_item_array = array();
							foreach($rows_other_items as $row_other_item){
								$other_item_array[] = $row_other_item->item_id;					
							}	
							//print_r($other_item_array);					
							  													
							//get all items which store their data in #__content. only those can be duplicated. so excluding the itemtypes which can be installed separately, like plugins, except for custom-itemtypes, they work fine.
							$class_pi->db->setQuery("SELECT id, title, sectionid, catid FROM #__content  WHERE state='0' OR state='1' ORDER BY title");
							$class_pi->db->setQuery( "SELECT c.id, c.title, c.sectionid, c.catid, i.itemtype"
							. "\nFROM #__content AS c"		
							. "\nLEFT JOIN #__pi_item_index AS i"
							. "\nON c.id=i.item_id"							
							. "\nWHERE (c.state='0' OR c.state='1')"
							. "\nORDER BY c.title ASC"
							);
							$all_items_db = $class_pi->db->loadObjectList();
							
							//get sections
							$class_pi->db->setQuery("SELECT id, title FROM #__sections");
							$all_sections_db = $class_pi->db->loadObjectList();
							
							//get categories
							$class_pi->db->setQuery("SELECT id, title FROM #__categories");
							$all_categories_db = $class_pi->db->loadObjectList();
								
							echo '<p>'._pi_lang_other_item_info.'</p>';
							
							if(!$other_item_id){
								$other_item_id = $class_pi->get_var('other_item_id');
							}
								
							//display select with items
							echo '<select name="other_item_id">';
							echo '<option value="0">'._pi_lang_select_an_item.'</option>';
							foreach($all_items_db as $item_db){
								//if not a other_item or itemtype-plugin which does not save data straight into table #__content
								if(!in_array($item_db->id ,$other_item_array) && !file_exists(dirname(__FILE__).'/../../com_pi_itemtype_'.$item_db->itemtype.'/com_pi_itemtype_'.$item_db->itemtype.'.xml')){
									echo '<option value="'.$item_db->id.'"';
									if($item_db->id==$other_item_id){
										echo ' selected="selected"';
									}
									echo '>';								
									echo $item_db->title;
									foreach($all_sections_db as $section_row){
										if($section_row->id==$item_db->sectionid){
											echo ' ['.$section_row->title.'/';
											break;
										}
									}
									foreach($all_categories_db as $category_row){
										if($category_row->id==$item_db->catid){
											echo $category_row->title.']';
											break;
										}
									}
								}
								echo '</option>';
							}
							echo '</select>';
							
							/*
							//get catid of original item
							foreach($all_items_db as $item_db){
								if($item_db->id==$other_item_id){
									$original_cat_id = $item_db->catid;
									break;
								}								
							}
							*/
							
							//find the page_id
							$original_page_id = $class_pi->get_page_id_from_item_id($other_item_id);
							
							if($other_item_id){
								if($frontend){
									echo '<p><a href="index.php?option=com_pi_pages_and_items&task=item&sub_task=edit&pageId='.$original_page_id.'&item_id='.$other_item_id.'">'._pi_lang_edit_original_item.'</a></p>';
								}else{
									echo '<p><a href="index2.php?option=com_pi_pages_and_items&task=item&sub_task=edit&pageId='.$original_page_id.'&itemId='.$other_item_id.'">'._pi_lang_edit_original_item.'</a></p>';
								}						
							}
							
						}else{	
							if(strpos($item_type, 'ustom_')){
								//custom itemtype										
								$pos = strpos($item_type, 'ustom_');
								$type_id = substr($item_type, $pos+6, strlen($item_type));
								
								//if joomla 1.0.x get javascript for editor
								if(!defined('_JEXEC') ){
									//joomla version 1.0.x 				
									global $_MAMBOTS;
									$_MAMBOTS->loadBotGroup( 'editors-xtd' );		
									$mainframe->set( 'loadEditor', true );	
								
								}//end if joomla 1.0.x 
								
								//get fields config
								$class_pi->db->setQuery( "SELECT * "														
								. "\nFROM #__pi_custom_fields "									
								. "\nWHERE type_id='$type_id' "																								
								. "\nORDER BY ordering ASC"
								);
								$fields = $class_pi->db->loadObjectList();
								
								//get fieldsvalues
								$class_pi->db->setQuery( "SELECT * "														
								. "\nFROM #__pi_custom_fields_values "									
								. "\nWHERE item_id='$item_id' "																								
								);
								$fields_data = $class_pi->db->loadObjectList();								
								
								$validation_array = array();
								
								foreach($fields as $field){
														
										//explode params
										$field_params = '';										
										$temp = $field->params;
										$temp = explode( '[;-)# ]', $temp);	
										for($n = 0; $n < count($temp); $n++){	
											$temp2 = explode('-=-',$temp[$n]);
											$var = $temp2[0];
											$value = '';
											if(count($temp2)==2){
												$value = $temp2[1];
											}							
											$field_params[$var] = trim($value);	
										}									
										
										//if the field got field data, get values
										$field_values = '';
										$new_field = 1;
										$field_value = '';										
										foreach($fields_data as $field_data){
											if($field_data->field_id==$field->id){
												//explode values									
												$field_value = $field_data->value;
												$temp = explode( '[;-)# ]', $field_value);													
												for($n = 0; $n < count($temp); $n++){
													//list($var,$value) = split('-=-',$temp[$n]); 
													//$field_values[$var] = trim($value);													
													$temp2 = explode('-=-',$temp[$n]);
													$var = $temp2[0];
													$value = '';
													if(count($temp2)==2){
														$value = $temp2[1];
													}							
													$field_values[$var] = trim($value);													
												}												
												$new_field = 0;
												break;
											}												
										}
										
										//if($new_field){
											//$field_id = 'field_values_'.$field->id.'_new';												
										//}else{
											$field_id = 'field_values_'.$field->id;
										//}
										
										//get language for fieldtype plugin, defaults to english
										$class_pi->get_fieldtype_language($field->plugin);
										
										$validation_type = 0;										
										
										//check for validation param
										if($class_pi->check_if_field_param_is_present($field_params, 'validation')){
											$validation_type = $field_params['validation'];	
										}																			
										if($validation_type){
											$alert_message = $field_params['alert_message'];	
											$temp = array($field->plugin, $field_id, $validation_type, $alert_message, $field->name);
											array_push($validation_array, $temp);
										}
										
										$field->item_id = $item_id;	
										
										$class_pi->include_field_class($field->plugin);
										$class_name = 'class_fieldtype_'.$field->plugin;
										$class_plugin = new $class_name();
										echo $class_plugin->display_item_edit($field, $field_params, $field_values, $field_value, $new_field, $field_id);	
																																				
								}//end loop fields
								
								
								
								//print_r($validation_array);	
																
								
								//make javascript formvalidation script	
								echo "<script language=\"javascript\"  type=\"text/javascript\">\n";
								echo "<!--\n";	
								echo "function validate_custom_itemtype_fields(){\n\n";
								echo "is_valid = true;\n";					
								for($n = 0; $n < count($validation_array); $n++){
									echo 'field_id=\''.$validation_array[$n][1].'\';'."\n";
									echo 'field_name=\''.addslashes($validation_array[$n][4]).'\';'."\n";
									echo 'alert_message=\''.addslashes($validation_array[$n][3]).'\';'."\n";
									if(in_array($validation_array[$n][0],$class_pi->fieldtypes_integrated)){
										include(dirname(__FILE__).'/../javascript/validation_'.$validation_array[$n][0].'_'.$validation_array[$n][2].'.js');	
									}else{
										if(file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/fieldtypes/'.$validation_array[$n][0].'/'.$validation_array[$n][2].'.js')){										
											include(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/fieldtypes/'.$validation_array[$n][0].'/'.$validation_array[$n][2].'.js');												
										}
									}
									echo "\n\n";		
								}
								//echo "alert(document.getElementById('field_values_35').value);";
								echo "return is_valid;\n";
								echo "};\n";
								//close javascript
								echo "//-->\n";
								echo "</script>\n";
								
															
							}else{
								//plugin itemtype
								//get itemtype class
								$class_name = 'class_itemtype_'.$item_type;
								$class_pi->include_itemtype_class($item_type);	
								$class_itemtype = new $class_name();															
								include(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/admin/item.php');
								
								echo "<script language=\"javascript\"  type=\"text/javascript\">\n";
								echo "<!--\n";	
								echo "function validate_itemtype(){\n\n";
								echo "is_valid = true;\n";	
								echo "alert_message = \"";
								if($class_pi->check_if_plugin_lang_var_is_present($pi_lang_plugin, 'alert_message')){
									echo $pi_lang_plugin['alert_message'];
								}
								echo "\";\n";
								if(file_exists(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/admin/item_validation.js')){
									include(dirname(__FILE__).'/../../../../'.$class_pi->plugin_dir.'/pages_and_items/itemtypes/'.$item_type.'/admin/item_validation.js');
								}
								echo "return is_valid;\n";
								echo "};\n";
								//close javascript
								echo "//-->\n";
								echo "</script>\n";
								
							}						
						}	
						
					if(!$frontend){
						echo '</td><td width="210" valign="top">';						
					}				
						
					?>															
				  
				  <style type="text/css">
				  
				  		div#tabs_item div.tab-row h2.tab{
							margin-left: 10px;
						}
						
						div#tabs_item h2.tab a{
							padding: 2px 10px;
							display: block;							
						}	
											
					</style>	
				  
					<?php
					
					
					
					/*
					output of generated code:
						<div class="dynamic-tab-pane-control tab-page" id="tabs_item"><div class="tab-row"><h2 class="tab selected"><a href="#">Publiceren</a></h2><h2 class="tab"><a href="#">&nbsp;&nbsp;Lees verder</a></h2></div>
						*/
						
					//code for tabs, version specific, part 1
					if(defined('_JEXEC') && $class_pi->pi_config['item_menu']=='slide'){
						//joomla 1.5
						echo '<div id="content-pane" class="pane-sliders">
			<div class="panel"><h3 class="jpane-toggler title" id="detail-page"><span>'._pi_lang_publishing.'</span></h3>
				<div class="jpane-slider content">';
					}else{
						//joomla 1.0.x
						echo '<div class="tab-page" id="tabs_item">
						<script type="text/javascript">
							var tabPane1 = new WebFXTabPane( document.getElementById( "tabs_item" ), 1 )
						</script>
						<div class="tab-page" id="publishing">
							<h2 class="tab">'._pi_lang_publishing.'</h2>
							<script type="text/javascript">
								tabPane1.addTabPage( document.getElementById( "publishing" ) );
							</script>';
					}
					?>						
							
							<table class="adminform">
								<tr>
									<th colspan="2">
										<?php echo _pi_lang_publishing_info; ?>
									</th>
								</tr>								
				
				<tr <?php if(!$class_pi->check_display_item_property('item_props_title',89)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right" width="120">
					<?php echo _pi_lang_show_title; ?>:</td>
	
					<td>
					<input type="checkbox" name="show_title_item" value="1" <?php if($show_title_item){ echo "checked=\"checked\""; }?> />
					
						
					</td>
				</tr>						
				<tr <?php if(!$class_pi->check_display_item_property('item_props_access',90)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right" width="120">
					<?php echo _pi_lang_access; ?>:</td>
					<td>
	
					
	<select name="access" class="inputbox">
	<option value="0" <?php if($itemAccess==0){echo "selected=\"selected\"";} ?>><?php echo _pi_lang_public; ?></option>
	<option value="1" <?php if($itemAccess==1){echo "selected=\"selected\"";} ?>><?php echo _pi_lang_logged; ?></option>
	<option value="2" <?php if($itemAccess==2){echo "selected=\"selected\"";} ?>><?php echo _pi_lang_special; ?></option>
	</select>
	</td>
				</tr>					
				<tr <?php if(!$class_pi->check_display_item_property('item_props_author_alias',92)){echo 'class="display_none"'; } ?>>
	
					<td valign="top" align="right">
					<?php echo _pi_lang_author_alias; ?>:
					</td>
					<td>
					<input type="text" name="created_by_alias" size="30" maxlength="100" value="<?php echo $itemCreatedByAlias; ?>" class="text_area" />
					</td>
				</tr>
				<?php
				if($sub_task=='edit'){
				?>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_author',91)){echo 'class="display_none"'; } ?>>
						<td valign="top" align="right">	
						<?php echo _pi_lang_change_creator; ?>:
						</td>
						<td>
							<select name="created_by" class="inputbox" size="1"  style="width:103px;" >
							<?php
							//get usernames
							$class_pi->db->setQuery("SELECT id, name FROM #__users "  );
							$rows = $class_pi->db-> loadObjectList();
							foreach($rows as $row){	
								echo '<option value="'.$row->id.'"';
								if($row->id == $created_by){
									echo ' selected="selected"';
								}
								echo '>'.$row->name.'</option>';	
							}
							
							?>	
							</select>
						 </td>
					</tr>
				<?php
				}
				?>	
				<tr <?php if(!$class_pi->check_display_item_property('item_props_created_date',93)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
					<?php echo _pi_lang_created_date; ?>:
					</td>
					<td>
																		
					<?php
					if( defined('_JEXEC') ){
						//joomla 1.5
						/*
						echo '<img class="calendar" src="';
						if(!$frontend){
							echo '../';
						}
						echo 'templates/system/images/calendar.png" alt="calendar" id="detailscreated_img" />';
						*/
						//echo JHTML::calendar($created,'created', 'created',"%d-%m-%Y");
						echo JHTML::calendar($created,'created', 'created', $class_pi->pi_config['date_format']);
					}else{
						//joomla 1.0.x
						echo '<input class="text_area" type="text" name="created" id="created" size="25" maxlength="19" value="'.$created.'" />';
						echo '<input type="button" class="button" value="..." onclick="return showCalendar(\'created\', \'y-mm-dd\');">';
					}
					?>
					<input type="button" value="<?php echo _pi_lang_now; ?>" onclick="document.getElementById('created').value='<?php echo _pi_lang_now; ?>'" class="button calenderbutton" />						
					</td>
				</tr>						
				<tr <?php if(!$class_pi->check_display_item_property('item_props_publish_up',94)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
					<?php echo _pi_lang_start; ?>:
					</td>
					<td>
															
					<?php
					if( defined('_JEXEC') ){
						//joomla 1.5
						/*
						echo '<img class="calendar" src="';
						if(!$frontend){
							echo '../';
						}
						echo 'templates/system/images/calendar.png" alt="calendar" id="detailspublish_up_img" />';
						*/
						//echo JHTML::calendar($item_publish_up,'publish_up', 'publish_up',"%d-%m-%Y");
						echo JHTML::calendar($item_publish_up,'publish_up', 'publish_up', $class_pi->pi_config['date_format']);
						
					}else{
						//joomla 1.0.x
						echo '<input class="text_area" type="text" name="publish_up" id="publish_up" size="25" maxlength="19" value="'.$item_publish_up.'" />';
						echo '<input type="button" class="button" value="..." onclick="return showCalendar(\'publish_up\', \'y-mm-dd\');" />';
					}
					?>
					<input type="button" value="<?php echo _pi_lang_now; ?>" onclick="document.getElementById('publish_up').value='<?php echo _pi_lang_now; ?>'" class="button calenderbutton" />	
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_publish_down',95)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
					<?php echo _pi_lang_stop; ?>:
					</td>
					<td>
					
					<?php
					if( defined('_JEXEC') ){
						//joomla 1.5
						/*
						echo '<img class="calendar" src="';
						if(!$frontend){
							echo '../';
						}
						echo 'templates/system/images/calendar.png" alt="calendar" id="detailspublish_down_img" />';
						*/
						//echo JHTML::calendar($item_publish_down, 'publish_down', 'publish_down',"%d-%m-%Y");
						echo JHTML::calendar($item_publish_down, 'publish_down', 'publish_down', $class_pi->pi_config['date_format']);
					}else{
						//joomla 1.0.x
						echo '<input class="text_area" type="text" name="publish_down" id="publish_down" size="25" maxlength="19" value="'.$item_publish_down.'" />					';
						echo '<input type="button" class="button" value="..." onclick="return showCalendar(\'publish_down\', \'y-mm-dd\');" />';
					}
					?>
					<input type="button" value="<?php echo _pi_lang_never; ?>" onclick="document.getElementById('publish_down').value='<?php echo _pi_lang_never; ?>'" class="button calenderbutton" />	
					</td>
				</tr>
				<?php 
					if($sub_task=='edit'){
				?>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_hits',96)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
						<?php echo _pi_lang_hits; ?>
					</td>
					<td>
						<?php echo $item_hits; ?>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_version',97)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
						<?php echo _pi_lang_version; ?>
					</td>
					<td>
						<?php echo $version; ?>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_created',98)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
						<?php echo _pi_lang_created; ?>
					</td>
					<td>
						<?php echo $created; ?>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_modified',99)){echo 'class="display_none"'; } ?>>
					<td valign="top" align="right">
						<?php echo _pi_lang_modified; ?>
					</td>
					<td>
						<?php echo $item_modified; ?>
					</td>
				</tr>				
				
					<tr <?php if(!$class_pi->check_display_item_property('item_props_item_id',100)){echo 'class="display_none"'; } ?>>
						<td valign="top" align="right">
							<?php echo _pi_lang_item_id; ?>
						</td>
						<td>
							<?php echo $item_id; ?>
						</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_category_id',101)){echo 'class="display_none"'; } ?>>
						<td valign="top" align="right">
							<?php echo strtolower(_pi_lang_category_id); ?>
						</td>
						<td>
							<?php echo $cat_id; ?>
						</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_section_id',102)){echo 'class="display_none"'; } ?>>
						<td valign="top" align="right">
							<?php echo strtolower(_pi_lang_section_id); ?>
						</td>
						<td>
							<?php echo $section_id; ?>
						</td>						
					</tr>	
					<?php if($class_pi->check_display_item_property('item_props_other_items',131) && $item_type!='other_item'){ ?>
						<tr >
							<td valign="top" align="left" colspan="2">
								<?php echo _pi_lang_instances_of_this_item.':<br />'; ?>
							
								<?php 
								//get all instances of this item
								$class_pi->db->setQuery( "SELECT c.catid, c.sectionid, o.item_id"
								. "\nFROM #__content AS c"		
								. "\nLEFT JOIN #__pi_item_other_index AS o"
								. "\nON c.id=o.item_id"
								. "\nWHERE other_item_id='$item_id'"
								. "\nAND (c.state='0' OR c.state='1')"
								. "\nORDER BY c.ordering ASC"
								);		
								$instances_of_item = $class_pi->db->loadObjectList();
								
								//get sections
								$class_pi->db->setQuery("SELECT id, title FROM #__sections");
								$all_sections_db = $class_pi->db->loadObjectList();
								
								//get categories
								$class_pi->db->setQuery("SELECT id, title FROM #__categories");
								$all_categories_db = $class_pi->db->loadObjectList();
								
								if(count($instances_of_item)){
									echo '<ul>';
									foreach($instances_of_item as $instance_of_item){
										//find the page_id
										foreach($class_pi->menuitems as $menu_item_page){
											$temp_cat_id = 0;
											//if category blog											
											if((defined('_JEXEC') && strstr($menu_item_page->link, 'index.php?option=com_content&view=category&layout=blog') && $menu_item_page->type!='url' && $menu_item_page->type=='component') ||
											(!defined('_JEXEC') && $menu_item_page->type=='content_blog_category')
											){
												//get the category id of each menu item
												$pos_cat_id = strpos($menu_item_page->link,'id=');
												$temp_cat_id = substr($menu_item_page->link, ($pos_cat_id+3), strlen($menu_item_page->link));
												if($instance_of_item->catid==$temp_cat_id){
													$original_page_id = $menu_item_page->id;
													break;
												}
											}
										}
										if($frontend){
											echo '<li><a href="index.php?option=com_pi_pages_and_items&task=item&sub_task=edit&pageId='.$original_page_id.'&item_id='.$instance_of_item->item_id.'">';
										}else{
											echo '<li><a href="index2.php?option=com_pi_pages_and_items&task=item&sub_task=edit&pageId='.$original_page_id.'&itemId='.$instance_of_item->item_id.'">';
										}								
																			
										foreach($all_sections_db as $section_row){
											if($section_row->id==$instance_of_item->sectionid){
												echo ''.$section_row->title.'/';
												break;
											}
										}
										foreach($all_categories_db as $category_row){
											if($category_row->id==$instance_of_item->catid){
												echo $category_row->title.'';
												break;
											}
										}
										echo '</a></li>';
									}
									echo '</ul>';
								}else{
									echo _pi_lang_no_instances;
								}
								
								echo '<br />';
								echo '<a href="index.php?option=com_pi_pages_and_items&task=';
								if($frontend){
									echo 'item&type=content_blog_category&sub_task=new&pageId=0&item_type=other_item';
								}else{
									echo 'instance_select';
								}
								echo '&other_item_id='.$item_id.'">'._pi_lang_create_instance.'</a>';
								
								?>
							</td>						
						</tr>
				<?php
					}//end if item-edit
				?>		
					<?php } ?>		
				</table>
						<?php
						
						//code for tabs part 2
						if(defined('_JEXEC') && $class_pi->pi_config['item_menu']=='slide'){
							//joomla 1.5
							echo '</div>
			</div>
			<div class="panel"><h3 class="jpane-toggler title" id="detail-page"><span>'._pi_lang_readmore.'</span></h3>
				<div class="jpane-slider content">';
						}else{
							//joomla 1.0.x
							echo '</div>	
												
						<div class="tab-page" id="read_more">
							<h2 class="tab">'._pi_lang_readmore.'</h2>
							<script type="text/javascript">
								tabPane1.addTabPage( document.getElementById( "read_more" ) );
							</script>';
						}
						?>	
							
													
							<table class="adminform">
				
				<tr>
					<th colspan="2">
						<?php echo _pi_lang_props_for.'<br />'. _pi_lang_readmore.' '._pi_lang_page; ?>						
					</th>
				</tr>				
				<tr <?php if(!$class_pi->check_display_item_property('item_props_title',103)){echo 'class="display_none"'; } ?>>
					<td valign="top">						
						<span class="editlinktip"><span onMouseOver="return overlib('<?php echo _pi_lang_itemtitle_tip; ?>', CAPTION, '<?php echo _pi_lang_itemtitle; ?>', BELOW, RIGHT);" onMouseOut="return nd();" ><?php echo _pi_lang_itemtitle; ?></span></span>						
					</td>	
					<td>	
					
						<?php
						if( defined('_JEXEC') ){
							//joomla 1.5
							?>
							<select name="itemAttribs[show_title]" class="inputbox">
								<option value="" <?php if($values['show_title']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
								<option value="0" <?php if($values['show_title']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
								<option value="1" <?php if($values['show_title']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
							</select>
							<?php
						}else{
							//joomla 1.0.x
							?>
							<input type="radio" name="itemAttribs[item_title]" id="itemAttribs[item_title]0" value="0" <?php if($values['item_title']==0){ echo "checked=\"checked\""; }?>  />
							<label for="itemAttribs[item_title]0"><?php echo _pi_lang_hide; ?></label><br />
							<input type="radio" name="itemAttribs[item_title]" id="itemAttribs[item_title]1" value="1" <?php if($values['item_title']==1){ echo "checked=\"checked\""; }?> />					
							<label for="itemAttribs[item_title]1"><?php echo _pi_lang_show; ?></label>
							<?php						
						}
						?>						
					</td>
				</tr>				
				<tr <?php if(!$class_pi->check_display_item_property('item_props_pdf_link',104)){echo 'class="display_none"'; } ?>>
					<td>
					<span class="editlinktip"><span onMouseOver="return overlib('<?php echo _pi_lang_pdf_link_tip; ?>', CAPTION, '<?php echo _pi_lang_pdf_link; ?>', BELOW, RIGHT);" onMouseOut="return nd();" ><?php echo _pi_lang_pdf_link; ?></span></span>
					</td>
					<td>
					<?php
						//rename attributes for joomla 1.5
						if( defined('_JEXEC') ){
							//joomla 1.5
							$pdf = 'show_pdf_icon';
							$print = 'show_print_icon';
							$email = 'show_email_icon';								
							$rating = 'show_vote';
							$author = 'show_author';
							$createdate = 'show_create_date';
							$modifydate = 'show_modify_date';
						}else{
							//joomla 1.0.x
							$pdf = 'pdf';
							$print = 'print';
							$email = 'email';							
							$rating = 'rating';
							$author = 'author';
							$createdate = 'createdate';
							$modifydate = 'modifydate';
						}

						
					?>
					<select name="itemAttribs[<?php echo $pdf; ?>]" class="inputbox">
						<option value="" <?php if($values[$pdf]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$pdf]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1" <?php if($values[$pdf]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_print_link',105)){echo 'class="display_none"'; } ?>>
					<td>
					<span class="editlinktip">
					<span onMouseOver="return overlib('<?php echo _pi_lang_print_link_tip; ?>', CAPTION, '<?php echo _pi_lang_print_link; ?>', BELOW, RIGHT);" onMouseOut="return nd();" ><?php echo _pi_lang_print_link; ?></span></span></td>
					<td>
					<select name="itemAttribs[<?php echo $print; ?>]" class="inputbox">
						<option value="" <?php if($values[$print]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$print]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>
					
						<option value="1" <?php if($values[$print]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_mail_link',106)){echo 'class="display_none"'; } ?>>
					<td>
					<span class="editlinktip">
					<span onMouseOver="return overlib('<?php echo _pi_lang_mail_link_tip; ?>', CAPTION, '<?php echo _pi_lang_mail_link; ?>', BELOW, RIGHT);" onMouseOut="return nd();" ><?php echo _pi_lang_mail_link; ?></span></span></td>
					<td>
						<select name="itemAttribs[<?php echo $email; ?>]" class="inputbox">
							<option value="" <?php if($values[$email]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
							<option value="0" <?php if($values[$email]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>
						
							<option value="1" <?php if($values[$email]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
						</select>					
					</td>
				</tr>					
				
				
				<?php
						//pagesuffix and back-button only for joomla 1.0.x (why?)
						if( !defined('_JEXEC') ){
						?>
				<tr>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_page_class_suffix_tip; ?>', CAPTION, '<?php echo _pi_lang_page_class_suffix; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_page_class_suffix; ?></span></span></td>
					<td><input type="text" name="itemAttribs[pageclass_sfx]" value="<?php echo $values['pageclass_sfx']; ?>" class="text_area" size="20" /></td>
					</tr>
					
					
					<tr>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_back_tip; ?>', CAPTION, '<?php echo _pi_lang_back; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_back; ?></span></span></td>
					<td>
					<select name="itemAttribs[back_button]" class="inputbox">
						<option value="" <?php if($values['back_button']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>					
						<option value="0" <?php if($values['back_button']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_no; ?></option>
						<option value="1" <?php if($values['back_button']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_yes; ?></option>
					</select>
					</td>
					</tr>
					<?php
					}//end if pagesuffix and back-button only for joomla 1.0.x 
					?>				
					<tr <?php if(!$class_pi->check_display_item_property('item_props_linked_titles',107)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_linked_titles_tip; ?>', CAPTION, '<?php echo _pi_lang_linked_titles; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_linked_titles; ?></span></span></td>
					<td>
					<select name="itemAttribs[link_titles]" class="inputbox">
						<option value="" <?php if($values['link_titles']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['link_titles']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_no; ?></option>					
						<option value="1"  <?php if($values['link_titles']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_yes; ?></option>
					</select>
					</td>
					</tr>
					
<?php
//joomla 1.5 parameters that have 3 options (selects), whereas in joomla 1.0.x there are oly 2 (radio's)
if( defined('_JEXEC') ){
	//joomla 1.5
?>
<tr <?php if(!$class_pi->check_display_item_property('item_props_intro',108)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_intro_tip; ?>', CAPTION, '<?php echo _pi_lang_intro; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_intro; ?></span></span></td>
<td>
	<select name="itemAttribs[show_intro]" class="inputbox">
						<option value="" <?php if($values['show_intro']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['show_intro']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1"  <?php if($values['show_intro']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_section',109)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_section_tip; ?>', CAPTION, '<?php echo _pi_lang_section; ?>e', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_section; ?></span></span></td>
<td>
	<select name="itemAttribs[show_section]" class="inputbox">
						<option value="" <?php if($values['show_section']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['show_section']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1"  <?php if($values['show_section']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_section_link',110)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_section_link_tip; ?>', CAPTION, '<?php echo _pi_lang_section_link; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_section_link; ?></span></span></td>
<td>
	<select name="itemAttribs[link_section]" class="inputbox">
						<option value="" <?php if($values['link_section']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['link_section']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_no; ?></option>					
						<option value="1"  <?php if($values['link_section']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_yes; ?></option>
					</select>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_category',111)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_category_tip; ?>', CAPTION, '<?php echo _pi_lang_category; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_category; ?></span></span></td>
<td>
	<select name="itemAttribs[show_category]" class="inputbox">
						<option value="" <?php if($values['show_category']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['show_category']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1"  <?php if($values['show_category']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_category_link',112)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_category_link_tip; ?>', CAPTION, '<?php echo _pi_lang_category_link; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_category_link; ?></span></span></td>
<td>
	<select name="itemAttribs[link_category]" class="inputbox">
						<option value="" <?php if($values['link_category']==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0"  <?php if($values['link_category']=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_no; ?></option>					
						<option value="1"  <?php if($values['link_category']=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_yes; ?></option>
					</select>
</td>
</tr>					
<?php
	//end joomla1.5
}else{
	//joomla 1.0.x
?>					
<tr <?php if(!$class_pi->check_display_item_property('item_props_intro',108)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_intro_tip; ?>', CAPTION, '<?php echo _pi_lang_intro; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_intro; ?></span></span></td>
<td>
	<input type="radio" name="itemAttribs[introtext]" id="itemAttribs[introtext]0" value="0" <?php if($values['introtext']==0){ echo "checked=\"checked\""; }?> />
	<label for="itemAttribs[introtext]0"><?php echo _pi_lang_hide; ?></label><br />
	<input type="radio" name="itemAttribs[introtext]" id="itemAttribs[introtext]1" value="1" <?php if($values['introtext']==1){ echo "checked=\"checked\""; }?> />

	<label for="itemAttribs[introtext]1"><?php echo _pi_lang_show; ?></label>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_section',109)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_section_tip; ?>', CAPTION, '<?php echo _pi_lang_section; ?>e', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_section; ?></span></span></td>
<td>
	<input type="radio" name="itemAttribs[section]" id="itemAttribs[section]0" value="0" <?php if($values['section']==0){ echo "checked=\"checked\""; }?>  />
	<label for="itemAttribs[section]0"><?php echo _pi_lang_hide; ?></label><br />
	<input type="radio" name="itemAttribs[section]" id="itemAttribs[section]1" value="1" <?php if($values['section']==1){ echo "checked=\"checked\""; }?> />

	<label for="itemAttribs[section]1"><?php echo _pi_lang_show; ?></label>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_section_link',110)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_section_link_tip; ?>', CAPTION, '<?php echo _pi_lang_section_link; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_section_link; ?></span></span></td>
<td>
	<input type="radio" name="itemAttribs[section_link]" id="itemAttribs[section_link]0" value="0" <?php if($values['section_link']==0){ echo "checked=\"checked\""; }?>  />
	<label for="itemAttribs[section_link]0"><?php echo _pi_lang_no; ?></label><br />
	<input type="radio" name="itemAttribs[section_link]" id="itemAttribs[section_link]1" value="1" <?php if($values['section_link']==1){ echo "checked=\"checked\""; }?> />

	<label for="itemAttribs[section_link]1"><?php echo _pi_lang_yes; ?></label>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_category',111)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_category_tip; ?>', CAPTION, '<?php echo _pi_lang_category; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_category; ?></span></span></td>
<td>
	<input type="radio" name="itemAttribs[category]" id="itemAttribs[category]0" value="0" <?php if($values['category']==0){ echo "checked=\"checked\""; }?> />
	<label for="itemAttribs[category]0"><?php echo _pi_lang_hide; ?></label><br />
	<input type="radio" name="itemAttribs[category]" id="itemAttribs[category]1" value="1" <?php if($values['category']==1){ echo "checked=\"checked\""; }?> />

	<label for="itemAttribs[category]1"><?php echo _pi_lang_show; ?></label>
</td>
</tr>
<tr <?php if(!$class_pi->check_display_item_property('item_props_category_link',112)){echo 'class="display_none"'; } ?>>
<td align="right" valign="top"><span class="editlinktip">
<span onmouseover="return overlib('<?php echo _pi_lang_category_link_tip; ?>', CAPTION, '<?php echo _pi_lang_category_link; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_category_link; ?></span></span></td>
<td>
	<input type="radio" name="itemAttribs[category_link]" id="itemAttribs[category_link]0" value="0" <?php if($values['category_link']==0){ echo "checked=\"checked\""; }?>  />
	<label for="itemAttribs[category_link]0"><?php echo _pi_lang_no; ?></label><br />
	<input type="radio" name="itemAttribs[category_link]" id="itemAttribs[category_link]1" value="1" <?php if($values['category_link']==1){ echo "checked=\"checked\""; }?> />

	<label for="itemAttribs[category_link]1"><?php echo _pi_lang_yes; ?></label>
</td>
</tr>
					
					
<?php
}//end joomla 1.0.x
?>
					
					
					
					<tr <?php if(!$class_pi->check_display_item_property('item_props_rating',113)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_rating_tip; ?>', CAPTION, '<?php echo _pi_lang_rating; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_rating; ?></span></span></td>
					<td>
					<select name="itemAttribs[<?php echo $rating; ?>]" class="inputbox">
						<option value="" <?php if($values[$rating]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$rating]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>
					
						<option value="1" <?php if($values[$rating]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_author_names',114)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_author_tip; ?>', CAPTION, '<?php echo _pi_lang_author; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_author; ?></span></span></td>
					<td>
					<select name="itemAttribs[<?php echo $author; ?>]" class="inputbox">
						<option value="" <?php if($values[$author]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$author]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1" <?php if($values[$author]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_date',115)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_date_tip; ?>', CAPTION, '<?php echo _pi_lang_date; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_date; ?></span></span></td>
					<td>
					<select name="itemAttribs[<?php echo $createdate; ?>]" class="inputbox">
						<option value="" <?php if($values[$createdate]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$createdate]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1" <?php if($values[$createdate]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_mod_date',116)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_mod_date_tip; ?>', CAPTION, '<?php echo _pi_lang_mod_date; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_mod_date; ?></span></span></td>
					<td>
					<select name="itemAttribs[<?php echo $modifydate; ?>]" class="inputbox">
						<option value="" <?php if($values[$modifydate]==''){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_default; ?></option>
						<option value="0" <?php if($values[$modifydate]=='0'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_hide; ?></option>					
						<option value="1" <?php if($values[$modifydate]=='1'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_show; ?></option>
					</select>
					</td>
					</tr>
					<tr <?php if(!$class_pi->check_display_item_property('item_props_key',124)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top">					
					<span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_key_tip; ?>', CAPTION, '<?php echo _pi_lang_key; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_key; ?></span></span></td>
					<td><input type="text" name="itemAttribs[keyref]" value="<?php echo $values['keyref']; ?>" class="text_area" size="25" /></td>
					</tr>
					
					
					<?php 
					//language and readmore only in joomla 1.5
					if( defined('_JEXEC') ){
					?>
					
					<tr <?php if(!$class_pi->check_display_item_property('item_props_language',125)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><?php echo _pi_lang_language; ?></td>
					<td><input type="text" name="itemAttribs[language]" value="<?php if($sub_task=='new'){echo $language;}else{echo $values['language'];} ?>" class="text_area" size="25" /></td>
					</tr>
					
					<tr <?php if(!$class_pi->check_display_item_property('item_props_readmore',126)){echo 'class="display_none"'; } ?>>
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_readmore2_tip; ?>', CAPTION, '<?php echo _pi_lang_readmore2; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_readmore2; ?></span></span></td>
					<td>
<input type="text" name="itemAttribs[readmore]" value="<?php if($sub_task=='new'){echo $readmore;}else{echo $values['readmore'];} ?>" class="text_area" size="25" />
</td>
					</tr>					
					
					<?php 
					}//end if readmore
					
					//doctype only in joomla 1.0.x
					if( !defined('_JEXEC') ){
					?>
					<tr>
					
					<td align="right" valign="top"><span class="editlinktip">
					<span onmouseover="return overlib('<?php echo _pi_lang_doctype_tip; ?>', CAPTION, '<?php echo _pi_lang_doctype; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_doctype; ?></span></span></td>
					<td>
					<select name="itemAttribs[docbook_type]" class="inputbox">
						<option value="" <?php if($values['docbook_type']==''){ echo "selected=\"selected\""; }?>></option>
						<option value="appendix" <?php if($values['docbook_type']=='appendix'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_appendix; ?></option>
						<option value="article" <?php if($values['docbook_type']=='article'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_article; ?></option>
						<option value="book" <?php if($values['docbook_type']=='book'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_book; ?></option>
						<option value="chapter" <?php if($values['docbook_type']=='chapter'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_chapter; ?></option>					
						<option value="glossary" <?php if($values['docbook_type']=='glossary'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_glos; ?></option>
						<option value="part" <?php if($values['docbook_type']=='part'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_part; ?></option>
						<option value="refentry" <?php if($values['docbook_type']=='refentry'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_ref; ?></option>
						<option value="section" <?php if($values['docbook_type']=='section'){ echo "selected=\"selected\""; }?>><?php echo _pi_lang_section; ?></option>
					</select>
					</td>
				</tr>	
				<?php				
				}//end if doctype
				?>	
				<tr <?php if(!$class_pi->check_display_item_property('item_props_description',127)){echo 'class="display_none"'; } ?>>
					<td colspan="2">
						<?php echo _pi_lang_description; ?>:
						<br />
						<textarea class="text_area" cols="30" rows="3" style="width:161px; height:100px" name="metadesc" ><?php echo $itemMetadesc; ?></textarea>
					</td>
				</tr>
				<tr <?php if(!$class_pi->check_display_item_property('item_props_keywords',128)){echo 'class="display_none"'; } ?>>
					<td colspan="2">	
						<?php echo _pi_lang_keywords; ?>:
						<br />
						<textarea class="text_area" cols="30" rows="3" style="width:161px; height:100px" name="metakey" ><?php echo $itemMetakey; ?></textarea>
					</td>
				</tr>
	
<?php
//robots and author metadata only for joomla 1.5
if( defined('_JEXEC') ){
?>
				
<tr <?php if(!$class_pi->check_display_item_property('item_props_robots',129)){echo 'class="display_none"'; } ?>>
	<td align="right" valign="top"><span class="editlinktip">
	<span onmouseover="return overlib('<?php echo _pi_lang_robots_tip; ?>', CAPTION, '<?php echo _pi_lang_robots; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_robots; ?></span></span></td>
	<td>
		<input type="text" value="<?php echo $metadata_thing['robots']; ?>" name="metadata[robots]" class="text_area" size="25" />
	</td>
</tr>


<tr <?php if(!$class_pi->check_display_item_property('item_props_metaauthor',130)){echo 'class="display_none"'; } ?>>
	<td align="right" valign="top"><span class="editlinktip">
	<span onmouseover="return overlib('<?php echo _pi_lang_metaauthor_tip; ?>', CAPTION, '<?php echo _pi_lang_metaauthor; ?>', BELOW, RIGHT);" onmouseout="return nd();" ><?php echo _pi_lang_metaauthor; ?></span></span></td>
	<td>
		<input type="text" value="<?php echo $metadata_thing['author']; ?>" name="metadata[author]" class="text_area" size="25" />
	</td>
</tr>

<?php
}//end if robots and author metadata only for joomla 1.5
?>
					
											
			</table>
			<?php
			
				//code for tabs part 3
				if(defined('_JEXEC') && $class_pi->pi_config['item_menu']=='slide'){
					//joomla 1.5
					echo '</div';
				}
			?>
					</div>			
				</div>	
							  
			</td>
			</tr>
		  </table> </td>
		</tr>
		</table>
		<?php
		//submit buttons only at frontend		
		if($frontend){
			echo '<div class="right_align">';
			echo '<input type="button" value="'._pi_lang_save.'" onclick="submitbutton2(\'item_save\')" />&nbsp;&nbsp;&nbsp;';		
			echo '<input type="button" value="'._pi_lang_cancel.'" onclick="history.back();" />';
			echo '</div>';
		}else{			
			echo '<table class="toolbar"><tr>';
			echo '<td class="button" id="toolbar-save">';			
			echo '<a href="#" onclick="javascript: submitbutton(\'item_save\')" class="toolbar">';
			echo '<span class="icon-32-save" title="'._pi_lang_save.'"></span>'._pi_lang_save.'</a>';
			echo '</td>';
			echo '<td class="button" id="toolbar-apply">';
			echo '<a href="#" onclick="javascript: submitbutton(\'item_apply\')" class="toolbar">';
			echo '<span class="icon-32-apply" title="'._pi_lang_apply.'"></span>'._pi_lang_apply.'</a>';
			echo '</td>';
			echo '<td class="button" id="toolbar-cancel">';
			echo '<a href="#" onclick="javascript: submitbutton(\'cancel\')" class="toolbar">';
			echo '<span class="icon-32-cancel" title="'._pi_lang_cancel.'"></span>'._pi_lang_cancel.'</a></td></tr></table>';			
		}
		?>
	</form>
	
<?php


if(!$frontend){
	echo '</td></tr></table>';						
}
					
					
$class_pi->display_footer();
?>